package com.github.winyiwin.autoconfigure;

import com.github.winyiwin.KobeThreadPoolExecutor;
import com.github.winyiwin.KobeThreadPoolManager;
import com.github.winyiwin.KobeThreadPoolProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

@ConditionalOnClass(KobeThreadPoolExecutor.class)
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(KobeThreadPoolProperties.class)
public class KobeThreadPoolAutoConfiguration {


    @Lazy
    @Bean
    public KobeThreadPoolManager kobeThreadPoolManager(KobeThreadPoolProperties kobeThreadPoolProperties) {
        KobeThreadPoolManager manager = new KobeThreadPoolManager();
        manager.init(kobeThreadPoolProperties);
        return manager;
    }
}
